<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">




  
  
  <link rel="stylesheet" media="all" href="/lib/Han/dist/han.min.css?v=3.3">




<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="nginx goaccess 日志," />










<meta name="description" content="官方地址： https:&#x2F;&#x2F;goaccess.io 简介GoAccess 被设计成快速的并基于终端的日志分析工具。其核心理念是不需要通过 Web 浏览器就能快速分析并实时查看 Web 服务器的统计数据(这对于需要使用 SSH 来对访问日志进行快速分析或者就是喜欢在终端环境下工作的人来说是超赞的)。 终端输出仅仅是默认的输出方式，GoAccess 还支持生成完整的实时 HTML 报告(这对分析、监控">
<meta property="og:type" content="article">
<meta property="og:title" content="nginx日志分析工具:GoAccess">
<meta property="og:url" content="http://yoursite.com/2021/02/03/014/index.html">
<meta property="og:site_name" content="乐游さん 的博客~">
<meta property="og:description" content="官方地址： https:&#x2F;&#x2F;goaccess.io 简介GoAccess 被设计成快速的并基于终端的日志分析工具。其核心理念是不需要通过 Web 浏览器就能快速分析并实时查看 Web 服务器的统计数据(这对于需要使用 SSH 来对访问日志进行快速分析或者就是喜欢在终端环境下工作的人来说是超赞的)。 终端输出仅仅是默认的输出方式，GoAccess 还支持生成完整的实时 HTML 报告(这对分析、监控">
<meta property="og:image" content="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155639.png">
<meta property="og:image" content="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155347.png">
<meta property="og:image" content="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155017.png">
<meta property="article:published_time" content="2021-02-03T08:00:00.000Z">
<meta property="article:modified_time" content="2021-02-03T08:00:00.000Z">
<meta property="article:author" content="乐游">
<meta property="article:tag" content="nginx goaccess 日志">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155639.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2021/02/03/014/"/>





  <title>nginx日志分析工具:GoAccess | 乐游さん 的博客~</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?0492d48b6af5d10264fc93e94120c17c";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




<meta name="generator" content="Hexo 4.2.1"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
     

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">乐游さん 的博客~</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <h1 class="site-subtitle" itemprop="description">一直来自北方的程序猿 ~ </h1>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2021/02/03/014/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="乐游">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/WechatIMG22.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="乐游さん 的博客~">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">nginx日志分析工具:GoAccess</h2>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2021-02-03T16:00:00+08:00">
                2021-02-03
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于&#58;</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2021-02-03T16:00:00+08:00">
                2021-02-03
              </time>
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E8%BF%90%E7%BB%B4/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2021/02/03/014/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2021/02/03/014/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          
            <span class="post-meta-divider">|</span>
            <span class="page-pv"><i class="fa fa-file-o"></i> 阅读次数
            <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>
            </span>
          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body han-init-context" itemprop="articleBody">

      
      

      
        <p>官方地址： <a href="https://goaccess.io" target="_blank" rel="noopener">https://goaccess.io</a></p>
<h4 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h4><p>GoAccess 被设计成快速的并基于终端的日志分析工具。其核心理念是不需要通过 Web 浏览器就能快速分析并实时查看 Web 服务器的统计数据(这对于需要使用 SSH 来对访问日志进行快速分析或者就是喜欢在终端环境下工作的人来说是超赞的)。</p>
<p>终端输出仅仅是默认的输出方式，GoAccess 还支持生成完整的实时 HTML 报告(这对分析、监控以及数据可视化都是极好的)，以及 JSON 和 CSV 格式的报告。</p>
<h4 id="一、安装goaccess"><a href="#一、安装goaccess" class="headerlink" title="一、安装goaccess"></a>一、安装goaccess</h4><h5 id="1、安装依赖库"><a href="#1、安装依赖库" class="headerlink" title="1、安装依赖库"></a>1、安装依赖库</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install -y GeoIP-devel ncurses-devel</span><br></pre></td></tr></table></figure>

<h5 id="2、下载并安装GoAccess"><a href="#2、下载并安装GoAccess" class="headerlink" title="2、下载并安装GoAccess"></a>2、下载并安装GoAccess</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">wget https://tar.goaccess.io/goaccess-1.4.5.tar.gz</span><br><span class="line">tar -xzvf goaccess-1.4.5.tar.gz</span><br><span class="line"><span class="built_in">cd</span> goaccess-1.4.5/</span><br><span class="line">./configure --<span class="built_in">enable</span>-utf8 --<span class="built_in">enable</span>-geoip=legacy</span><br><span class="line">make &amp;&amp; make install</span><br></pre></td></tr></table></figure>
<p>注：如果你觉得麻烦，也可通过<code>yum</code>进行安装</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum install goaccess</span><br></pre></td></tr></table></figure>
<a id="more"></a>
<h5 id="3、配置日志格式"><a href="#3、配置日志格式" class="headerlink" title="3、配置日志格式"></a>3、配置日志格式</h5><p>配置文件位于：/usr/local/etc/goaccess/goaccess.conf</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">time-format %H:%M:%S</span><br><span class="line">date-format %d/%b/%Y</span><br><span class="line"><span class="built_in">log</span>-format %h - %^ [%d:%t %^]; <span class="string">"%r"</span> %s %b <span class="string">"%R"</span> - %^<span class="string">"%u"</span> - %^ %T</span><br></pre></td></tr></table></figure>

<h5 id="4、使用终端分析日志结果"><a href="#4、使用终端分析日志结果" class="headerlink" title="4、使用终端分析日志结果"></a>4、使用终端分析日志结果</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">goaccess -a -d -f /var/<span class="built_in">log</span>/nginx/access.log</span><br></pre></td></tr></table></figure>
<img src="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155639.png"/>

<h4 id="二、使用定时器以HTML格式输出分析结果"><a href="#二、使用定时器以HTML格式输出分析结果" class="headerlink" title="二、使用定时器以HTML格式输出分析结果"></a>二、使用定时器以HTML格式输出分析结果</h4><h5 id="1、编写脚本文件"><a href="#1、编写脚本文件" class="headerlink" title="1、编写脚本文件"></a>1、编写脚本文件</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#分析报告存放路径</span></span><br><span class="line">mkdir -p /data/www/goaccess/html</span><br><span class="line"><span class="comment">#分析脚本存放路径</span></span><br><span class="line">mkdir -p /usr/<span class="built_in">local</span>/goaccess/scripts</span><br><span class="line"><span class="comment">#获取HTML分析报告</span></span><br><span class="line">vim /usr/<span class="built_in">local</span>/goaccess/scripts/getHtmlReport-项目名称.sh</span><br></pre></td></tr></table></figure>
<ul>
<li>getHtmlReport-项目名称.sh内容如下:<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"><span class="comment">#页面转换为中文</span></span><br><span class="line">LANG=<span class="string">"zh_CN.UTF-8"</span></span><br><span class="line"><span class="comment">#输出HTML分析报告</span></span><br><span class="line">goaccess -a -d -f /var/<span class="built_in">log</span>/nginx/access.log -o /data/www/goaccess/html/report-项目名称.html</span><br></pre></td></tr></table></figure>

</li>
</ul>
<h5 id="2、分配脚本可执行权限："><a href="#2、分配脚本可执行权限：" class="headerlink" title="2、分配脚本可执行权限："></a>2、分配脚本可执行权限：</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">chmod 755 /usr/<span class="built_in">local</span>/goaccess/scripts/getHtmlReport-项目名称.sh</span><br></pre></td></tr></table></figure>

<h5 id="3、添加定时任务"><a href="#3、添加定时任务" class="headerlink" title="3、添加定时任务"></a>3、添加定时任务</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#新增定时任务</span></span><br><span class="line">crontab -e</span><br><span class="line"></span><br><span class="line"><span class="comment">#定时生成项目的nginx日志分析html报告</span></span><br><span class="line">0 0 * * * /bin/bash /usr/<span class="built_in">local</span>/goaccess/scripts/getHtmlReport-项目名称.sh</span><br></pre></td></tr></table></figure>
<h5 id="4、配置nginx访问路径"><a href="#4、配置nginx访问路径" class="headerlink" title="4、配置nginx访问路径"></a>4、配置nginx访问路径</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#用alias将它重定向到所指定的html中</span></span><br><span class="line">location /report-项目名称.html &#123;</span><br><span class="line">    <span class="built_in">alias</span> /data/www/goaccess/html/report-项目名称.html;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="三、nginx访问权限设置"><a href="#三、nginx访问权限设置" class="headerlink" title="三、nginx访问权限设置"></a>三、nginx访问权限设置</h4><p>nginx配置访问密码，让用户输入用户名密码才能访问(basicAuth)</p>
<p style="color:red">注：如果你是在内网进行使用，或者不考虑访问控制的问题，可以不进行 nginx 访问权限的设置</p>

<h5 id="1、安装htpassed工具"><a href="#1、安装htpassed工具" class="headerlink" title="1、安装htpassed工具"></a>1、安装htpassed工具</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install httpd-tools</span><br></pre></td></tr></table></figure>

<h5 id="2、设置用户名和密码，并把用户名、密码保存到指定文件中："><a href="#2、设置用户名和密码，并把用户名、密码保存到指定文件中：" class="headerlink" title="2、设置用户名和密码，并把用户名、密码保存到指定文件中："></a>2、设置用户名和密码，并把用户名、密码保存到指定文件中：</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">htpasswd -c [passwfile] [username]</span><br><span class="line"></span><br><span class="line"><span class="comment">#例：htpasswd -c /etc/nginx/passwd you</span></span><br></pre></td></tr></table></figure>
<img src="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155347.png"/>
注意：/etc/nginx/passwd 是生成密码后的文件保存路径(passwdfile)，codeauth是用户名（username）

<p>验证方法：查看最后生成的密码文件<code>/etc/nginx/passwd</code>的内容，分号后的内容就是加密过的密码。</p>
<h5 id="3、修改nginx配置文件"><a href="#3、修改nginx配置文件" class="headerlink" title="3、修改nginx配置文件"></a>3、修改nginx配置文件</h5><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">server &#123;</span><br><span class="line">        listen 443 ssl;</span><br><span class="line">        ......</span><br><span class="line">        </span><br><span class="line">        location /report-armstrong.html &#123;</span><br><span class="line">            <span class="comment">#新增下面两行</span></span><br><span class="line">            auth_basic <span class="string">"Please input password"</span>; <span class="comment">#这里是验证时的提示信息 </span></span><br><span class="line">            auth_basic_user_file /etc/nginx/passwd;</span><br><span class="line">            </span><br><span class="line">            <span class="built_in">alias</span> /data/www/goaccess/html/report-armstrong.html;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<h5 id="4、重启nginx并访问"><a href="#4、重启nginx并访问" class="headerlink" title="4、重启nginx并访问"></a>4、重启nginx并访问</h5><p>重启nginx，在浏览器中访问<code>/report-armstrong.html</code>，输入用户名和密码查看对应数据<br><img src="https://hyz-picgo-img.oss-cn-beijing.aliyuncs.com/20210203155017.png"/></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/nginx-goaccess-%E6%97%A5%E5%BF%97/" rel="tag"># nginx goaccess 日志</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/12/07/013/" rel="next" title="docker、containerd的关系">
                <i class="fa fa-chevron-left"></i> docker、containerd的关系
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2021/04/14/015/" rel="prev" title="Sublime Text 3 快捷键汇总">
                Sublime Text 3 快捷键汇总 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  <div>
    
    <div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">------ 本文结束------</div>
    
</div>
    
  </div>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/images/WechatIMG22.jpeg"
                alt="乐游" />
            
              <p class="site-author-name" itemprop="name">乐游</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/%7C%7C%20archive">
              
                  <span class="site-state-item-count">15</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">5</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#简介"><span class="nav-number">1.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#一、安装goaccess"><span class="nav-number">2.</span> <span class="nav-text">一、安装goaccess</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1、安装依赖库"><span class="nav-number">2.1.</span> <span class="nav-text">1、安装依赖库</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2、下载并安装GoAccess"><span class="nav-number">2.2.</span> <span class="nav-text">2、下载并安装GoAccess</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3、配置日志格式"><span class="nav-number">2.3.</span> <span class="nav-text">3、配置日志格式</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#4、使用终端分析日志结果"><span class="nav-number">2.4.</span> <span class="nav-text">4、使用终端分析日志结果</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#二、使用定时器以HTML格式输出分析结果"><span class="nav-number">3.</span> <span class="nav-text">二、使用定时器以HTML格式输出分析结果</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1、编写脚本文件"><span class="nav-number">3.1.</span> <span class="nav-text">1、编写脚本文件</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2、分配脚本可执行权限："><span class="nav-number">3.2.</span> <span class="nav-text">2、分配脚本可执行权限：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3、添加定时任务"><span class="nav-number">3.3.</span> <span class="nav-text">3、添加定时任务</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#4、配置nginx访问路径"><span class="nav-number">3.4.</span> <span class="nav-text">4、配置nginx访问路径</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#三、nginx访问权限设置"><span class="nav-number">4.</span> <span class="nav-text">三、nginx访问权限设置</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#1、安装htpassed工具"><span class="nav-number">4.1.</span> <span class="nav-text">1、安装htpassed工具</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2、设置用户名和密码，并把用户名、密码保存到指定文件中："><span class="nav-number">4.2.</span> <span class="nav-text">2、设置用户名和密码，并把用户名、密码保存到指定文件中：</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3、修改nginx配置文件"><span class="nav-number">4.3.</span> <span class="nav-text">3、修改nginx配置文件</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#4、重启nginx并访问"><span class="nav-number">4.4.</span> <span class="nav-text">4、重启nginx并访问</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2020 &mdash; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">乐游</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a></div>




        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv">
      <i class="fa fa-user"></i> 访问人数
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
      
    </span>
  

  
    <span class="site-pv">
      <i class="fa fa-eye"></i> 总访问量
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
      
    </span>
  
</div>








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  
  <script src="//cdn.jsdelivr.net/npm/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: false,
        notify: false,
        appId: 'ry4r48Li8ylactoROUmqjh7M-gzGzoHsz',
        appKey: 'vBcOR0V5lfk22hVzx04wUI57',
        placeholder: 'ヾﾉ≧∀≦)o 来呀！吐槽一番吧！',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  





  

  

  

  
  

  

  

  

</body>
</html>
